package com.zhkj.txg.module.product.model

import com.zhkj.lib.http.BaseApiService
import com.zhkj.lib.http.BaseResponse
import com.zhkj.txg.module.product.entity.*
import io.reactivex.Observable
import retrofit2.http.*

interface ProductApi : BaseApiService {
    @GET("api/goods/goodsInfo")
    fun product(
        @Query("token") token: String,
        @Query("id") id: Int,
        @Query("shop_id") shopId: Int = 0
    ): Observable<ProductResponse>

    @GET("api/goods/goodsInfo")
    fun product2(
        @Query("token") token: String,
        @Query("id") id: Int,
        @Query("shop_id") shopId: Int = 0
    ): Observable<ProductResponse2>

    @FormUrlEncoded
    @POST("api/cart/add")
    fun addCart(@FieldMap map: Map<String, String>): Observable<BaseResponse>

    @FormUrlEncoded
    @POST("api/goods/collectGoods")
    fun collectProduct(
        @Field("token") token: String,
        @Field("shop_id") shopId: Long,
        @Field("goods_id") goodsId: Long,
        @Field("type") type: String
    ): Observable<BaseResponse>

    @GET("api/goods/rankList")
    fun rankProduct(
        @Query("token") token: String,
        @Query("cat_id") catId: Long,
        @Query("page") page: Int,
        @Query("rows") rows: Int
    ): Observable<RankProductResponse>

    @GET("api/goods/comment")
    fun commentList(
        @Query("goods_id") goodsId: Long,
        @Query("type") type: Int, // 类型 默认0 0全部 1好评 2中评 3差评
        @Query("page") page: Int,
        @Query("rows") rows: Int
    ): Observable<CommentListResponse>

    @GET("api/common/getQrCode")
    fun getQRCode(@Query("token") token: String, @Query("goods_id") goodsId: Long): Observable<CodeResponse>
}